import { EntitySchema } from '@mikro-orm/core';

export class FailedJobs {
  id!: string;
  uuid!: string;
  connection!: string;
  queue!: string;
  payload!: unknown;
  exception!: unknown;
  failedAt!: Date;
}

export const FailedJobsSchema = new EntitySchema({
  class: FailedJobs,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    uuid: { type: 'string', length: 255, unique: 'failed_jobs_uuid_unique' },
    connection: { type: 'string', columnType: 'text' },
    queue: { type: 'string', columnType: 'text' },
    payload: { type: 'unknown', columnType: 'longtext' },
    exception: { type: 'unknown', columnType: 'longtext' },
    failedAt: { type: 'Date', length: 0, defaultRaw: `CURRENT_TIMESTAMP` },
  },
});
